#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Description :       .
@Date        : 2021/01/26 20:42:24
@Author      : wulinlin
@version     : 1.0
'''

class SortLinLin(object):

    def select_sort(self,arrays):
        """
        @description  : 使用选择排序对输入的数组进行选择排序
        @param  : 数组
        @Returns  : 排序好的数组
        """
        if len(arrays) < 1:
            return None
        arr_len = len(arrays)
        for i in range(arr_len):
            min_index = i
            for j in range(i+1,arr_len):
                if arrays[min_index] > arrays[j]:
                    min_index = j
            arrays[i],arrays[min_index] = arrays[min_index],arrays[i]
        return arrays

    def bubble_sort(self, arrays):
        if len(arrays) < 1:
            return None
        arr_len = len(arrays)
        for i in range(arr_len):
            for j in range(i+1,arr_len):
                if arrays[i]<arrays[j]:
                    arrays[i],arrays[j] = arrays[j],arrays[i]
        return arrays


if __name__ == "__main__":
    arrays = [2,4,1,5,7,2,6,1,8,10]
    obj = SortLinLin()
    # print(obj.select_sort(arrays))
    print(obj.bubble_sort(arrays))